db migration for new cleanup time

stvnrlly vor 9 Jahren
Ursprung
Commit
38a5dbfd87
2 geänderte Dateien mit 91 neuen Zeilen und 78 gelöschten Zeilen
  1. 13 0
      db/migrate/20150507153436_update_keep_events_for_to_be_in_seconds.rb
  2. 78 78
      db/schema.rb

+ 13 - 0
db/migrate/20150507153436_update_keep_events_for_to_be_in_seconds.rb

@@ -0,0 +1,13 @@
1
+class UpdateKeepEventsForToBeInSeconds < ActiveRecord::Migration
2
+  class Agent < ActiveRecord::Base; end
3
+
4
+  SECONDS_IN_DAY = 60 * 60 * 24
5
+
6
+  def up
7
+    Agent.update_all ['keep_events_for = keep_events_for * ?', SECONDS_IN_DAY]
8
+  end
9
+
10
+  def down
11
+    Agent.update_all ['keep_events_for = keep_events_for / ?', SECONDS_IN_DAY]
12
+  end
13
+end

+ 78 - 78
db/schema.rb

@@ -11,39 +11,39 @@
11 11
 #
12 12
 # It's strongly recommended that you check this file into your version control system.
13 13
 
14
-ActiveRecord::Schema.define(version: 20140906030139) do
15
-
16
-  create_table "agent_logs", force: true do |t|
17
-    t.integer  "agent_id",                      null: false
18
-    t.text     "message",                       null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
19
-    t.integer  "level",             default: 3, null: false
20
-    t.integer  "inbound_event_id"
21
-    t.integer  "outbound_event_id"
14
+ActiveRecord::Schema.define(version: 20150507153436) do
15
+
16
+  create_table "agent_logs", force: :cascade do |t|
17
+    t.integer  "agent_id",          limit: 4,                 null: false
18
+    t.text     "message",           limit: 65535,             null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
19
+    t.integer  "level",             limit: 4,     default: 3, null: false
20
+    t.integer  "inbound_event_id",  limit: 4
21
+    t.integer  "outbound_event_id", limit: 4
22 22
     t.datetime "created_at"
23 23
     t.datetime "updated_at"
24 24
   end
25 25
 
26
-  create_table "agents", force: true do |t|
27
-    t.integer  "user_id"
28
-    t.text     "options",                                                               charset: "utf8mb4", collation: "utf8mb4_bin"
29
-    t.string   "type",                                                                                      collation: "utf8_bin"
30
-    t.string   "name",                                                                  charset: "utf8mb4", collation: "utf8mb4_bin"
31
-    t.string   "schedule",                                                                                  collation: "utf8_bin"
32
-    t.integer  "events_count",                             default: 0,     null: false
26
+  create_table "agents", force: :cascade do |t|
27
+    t.integer  "user_id",               limit: 4
28
+    t.text     "options",               limit: 65535,                                   charset: "utf8mb4", collation: "utf8mb4_bin"
29
+    t.string   "type",                  limit: 191,                                                         collation: "utf8_bin"
30
+    t.string   "name",                  limit: 191,                                     charset: "utf8mb4", collation: "utf8mb4_bin"
31
+    t.string   "schedule",              limit: 191,                                                         collation: "utf8_bin"
32
+    t.integer  "events_count",          limit: 4,          default: 0,     null: false
33 33
     t.datetime "last_check_at"
34 34
     t.datetime "last_receive_at"
35
-    t.integer  "last_checked_event_id"
35
+    t.integer  "last_checked_event_id", limit: 4
36 36
     t.datetime "created_at"
37 37
     t.datetime "updated_at"
38
-    t.text     "memory",                limit: 2147483647,                              charset: "utf8mb4", collation: "utf8mb4_bin"
38
+    t.text     "memory",                limit: 4294967295,                              charset: "utf8mb4", collation: "utf8mb4_bin"
39 39
     t.datetime "last_web_request_at"
40
-    t.integer  "keep_events_for",                          default: 0,     null: false
40
+    t.integer  "keep_events_for",       limit: 4,          default: 0,     null: false
41 41
     t.datetime "last_event_at"
42 42
     t.datetime "last_error_log_at"
43
-    t.boolean  "propagate_immediately",                    default: false, null: false
44
-    t.boolean  "disabled",                                 default: false, null: false
45
-    t.integer  "service_id"
46
-    t.string   "guid",                                                     null: false
43
+    t.boolean  "propagate_immediately", limit: 1,          default: false, null: false
44
+    t.boolean  "disabled",              limit: 1,          default: false, null: false
45
+    t.integer  "service_id",            limit: 4
46
+    t.string   "guid",                  limit: 191,                        null: false
47 47
   end
48 48
 
49 49
   add_index "agents", ["guid"], name: "index_agents_on_guid", using: :btree
@@ -51,9 +51,9 @@ ActiveRecord::Schema.define(version: 20140906030139) do
51 51
   add_index "agents", ["type"], name: "index_agents_on_type", using: :btree
52 52
   add_index "agents", ["user_id", "created_at"], name: "index_agents_on_user_id_and_created_at", using: :btree
53 53
 
54
-  create_table "control_links", force: true do |t|
55
-    t.integer  "controller_id",     null: false
56
-    t.integer  "control_target_id", null: false
54
+  create_table "control_links", force: :cascade do |t|
55
+    t.integer  "controller_id",     limit: 4, null: false
56
+    t.integer  "control_target_id", limit: 4, null: false
57 57
     t.datetime "created_at"
58 58
     t.datetime "updated_at"
59 59
   end
@@ -61,25 +61,25 @@ ActiveRecord::Schema.define(version: 20140906030139) do
61 61
   add_index "control_links", ["control_target_id"], name: "index_control_links_on_control_target_id", using: :btree
62 62
   add_index "control_links", ["controller_id", "control_target_id"], name: "index_control_links_on_controller_id_and_control_target_id", unique: true, using: :btree
63 63
 
64
-  create_table "delayed_jobs", force: true do |t|
65
-    t.integer  "priority",                    default: 0
66
-    t.integer  "attempts",                    default: 0
64
+  create_table "delayed_jobs", force: :cascade do |t|
65
+    t.integer  "priority",   limit: 4,        default: 0
66
+    t.integer  "attempts",   limit: 4,        default: 0
67 67
     t.text     "handler",    limit: 16777215,             charset: "utf8mb4", collation: "utf8mb4_bin"
68
-    t.text     "last_error",                              charset: "utf8mb4", collation: "utf8mb4_bin"
68
+    t.text     "last_error", limit: 65535,                charset: "utf8mb4", collation: "utf8mb4_bin"
69 69
     t.datetime "run_at"
70 70
     t.datetime "locked_at"
71 71
     t.datetime "failed_at"
72
-    t.string   "locked_by"
73
-    t.string   "queue"
72
+    t.string   "locked_by",  limit: 191
73
+    t.string   "queue",      limit: 191
74 74
     t.datetime "created_at"
75 75
     t.datetime "updated_at"
76 76
   end
77 77
 
78 78
   add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
79 79
 
80
-  create_table "events", force: true do |t|
81
-    t.integer  "user_id"
82
-    t.integer  "agent_id"
80
+  create_table "events", force: :cascade do |t|
81
+    t.integer  "user_id",    limit: 4
82
+    t.integer  "agent_id",   limit: 4
83 83
     t.decimal  "lat",                         precision: 15, scale: 10
84 84
     t.decimal  "lng",                         precision: 15, scale: 10
85 85
     t.text     "payload",    limit: 16777215,                           charset: "utf8mb4", collation: "utf8mb4_bin"
@@ -92,20 +92,20 @@ ActiveRecord::Schema.define(version: 20140906030139) do
92 92
   add_index "events", ["expires_at"], name: "index_events_on_expires_at", using: :btree
93 93
   add_index "events", ["user_id", "created_at"], name: "index_events_on_user_id_and_created_at", using: :btree
94 94
 
95
-  create_table "links", force: true do |t|
96
-    t.integer  "source_id"
97
-    t.integer  "receiver_id"
95
+  create_table "links", force: :cascade do |t|
96
+    t.integer  "source_id",            limit: 4
97
+    t.integer  "receiver_id",          limit: 4
98 98
     t.datetime "created_at"
99 99
     t.datetime "updated_at"
100
-    t.integer  "event_id_at_creation", default: 0, null: false
100
+    t.integer  "event_id_at_creation", limit: 4, default: 0, null: false
101 101
   end
102 102
 
103 103
   add_index "links", ["receiver_id", "source_id"], name: "index_links_on_receiver_id_and_source_id", using: :btree
104 104
   add_index "links", ["source_id", "receiver_id"], name: "index_links_on_source_id_and_receiver_id", using: :btree
105 105
 
106
-  create_table "scenario_memberships", force: true do |t|
107
-    t.integer  "agent_id",    null: false
108
-    t.integer  "scenario_id", null: false
106
+  create_table "scenario_memberships", force: :cascade do |t|
107
+    t.integer  "agent_id",    limit: 4, null: false
108
+    t.integer  "scenario_id", limit: 4, null: false
109 109
     t.datetime "created_at"
110 110
     t.datetime "updated_at"
111 111
   end
@@ -113,71 +113,71 @@ ActiveRecord::Schema.define(version: 20140906030139) do
113 113
   add_index "scenario_memberships", ["agent_id"], name: "index_scenario_memberships_on_agent_id", using: :btree
114 114
   add_index "scenario_memberships", ["scenario_id"], name: "index_scenario_memberships_on_scenario_id", using: :btree
115 115
 
116
-  create_table "scenarios", force: true do |t|
117
-    t.string   "name",                         null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
118
-    t.integer  "user_id",                      null: false
116
+  create_table "scenarios", force: :cascade do |t|
117
+    t.string   "name",         limit: 191,                   null: false, charset: "utf8mb4", collation: "utf8mb4_bin"
118
+    t.integer  "user_id",      limit: 4,                     null: false
119 119
     t.datetime "created_at"
120 120
     t.datetime "updated_at"
121
-    t.text     "description",                               charset: "utf8mb4", collation: "utf8mb4_bin"
122
-    t.boolean  "public",       default: false, null: false
123
-    t.string   "guid",                         null: false, charset: "ascii",   collation: "ascii_bin"
124
-    t.string   "source_url"
125
-    t.string   "tag_bg_color"
126
-    t.string   "tag_fg_color"
121
+    t.text     "description",  limit: 65535,                              charset: "utf8mb4", collation: "utf8mb4_bin"
122
+    t.boolean  "public",       limit: 1,     default: false, null: false
123
+    t.string   "guid",         limit: 191,                   null: false, charset: "ascii",   collation: "ascii_bin"
124
+    t.string   "source_url",   limit: 191
125
+    t.string   "tag_bg_color", limit: 191
126
+    t.string   "tag_fg_color", limit: 191
127 127
   end
128 128
 
129 129
   add_index "scenarios", ["user_id", "guid"], name: "index_scenarios_on_user_id_and_guid", unique: true, using: :btree
130 130
 
131
-  create_table "services", force: true do |t|
132
-    t.integer  "user_id",                       null: false
133
-    t.string   "provider",                      null: false
134
-    t.string   "name",                          null: false
135
-    t.text     "token",                         null: false
136
-    t.text     "secret"
137
-    t.text     "refresh_token"
131
+  create_table "services", force: :cascade do |t|
132
+    t.integer  "user_id",       limit: 4,                     null: false
133
+    t.string   "provider",      limit: 191,                   null: false
134
+    t.string   "name",          limit: 191,                   null: false
135
+    t.text     "token",         limit: 65535,                 null: false
136
+    t.text     "secret",        limit: 65535
137
+    t.text     "refresh_token", limit: 65535
138 138
     t.datetime "expires_at"
139
-    t.boolean  "global",        default: false
140
-    t.text     "options"
139
+    t.boolean  "global",        limit: 1,     default: false
140
+    t.text     "options",       limit: 65535
141 141
     t.datetime "created_at"
142 142
     t.datetime "updated_at"
143
-    t.string   "uid"
143
+    t.string   "uid",           limit: 191
144 144
   end
145 145
 
146 146
   add_index "services", ["provider"], name: "index_services_on_provider", using: :btree
147 147
   add_index "services", ["uid"], name: "index_services_on_uid", using: :btree
148 148
   add_index "services", ["user_id", "global"], name: "index_services_on_user_id_and_global", using: :btree
149 149
 
150
-  create_table "user_credentials", force: true do |t|
151
-    t.integer  "user_id",                           null: false
152
-    t.string   "credential_name",                   null: false
153
-    t.text     "credential_value",                  null: false
150
+  create_table "user_credentials", force: :cascade do |t|
151
+    t.integer  "user_id",          limit: 4,                      null: false
152
+    t.string   "credential_name",  limit: 191,                    null: false
153
+    t.text     "credential_value", limit: 65535,                  null: false
154 154
     t.datetime "created_at"
155 155
     t.datetime "updated_at"
156
-    t.string   "mode",             default: "text", null: false, collation: "utf8_bin"
156
+    t.string   "mode",             limit: 191,   default: "text", null: false, collation: "utf8_bin"
157 157
   end
158 158
 
159 159
   add_index "user_credentials", ["user_id", "credential_name"], name: "index_user_credentials_on_user_id_and_credential_name", unique: true, using: :btree
160 160
 
161
-  create_table "users", force: true do |t|
162
-    t.string   "email",                              default: "",    null: false,                     collation: "utf8_bin"
163
-    t.string   "encrypted_password",                 default: "",    null: false, charset: "ascii",   collation: "ascii_bin"
164
-    t.string   "reset_password_token",                                                                collation: "utf8_bin"
161
+  create_table "users", force: :cascade do |t|
162
+    t.string   "email",                  limit: 191, default: "",    null: false,                     collation: "utf8_bin"
163
+    t.string   "encrypted_password",     limit: 191, default: "",    null: false, charset: "ascii",   collation: "ascii_bin"
164
+    t.string   "reset_password_token",   limit: 191,                                                  collation: "utf8_bin"
165 165
     t.datetime "reset_password_sent_at"
166 166
     t.datetime "remember_created_at"
167
-    t.integer  "sign_in_count",                      default: 0
167
+    t.integer  "sign_in_count",          limit: 4,   default: 0
168 168
     t.datetime "current_sign_in_at"
169 169
     t.datetime "last_sign_in_at"
170
-    t.string   "current_sign_in_ip"
171
-    t.string   "last_sign_in_ip"
170
+    t.string   "current_sign_in_ip",     limit: 191
171
+    t.string   "last_sign_in_ip",        limit: 191
172 172
     t.datetime "created_at"
173 173
     t.datetime "updated_at"
174
-    t.boolean  "admin",                              default: false, null: false
175
-    t.integer  "failed_attempts",                    default: 0
176
-    t.string   "unlock_token"
174
+    t.boolean  "admin",                  limit: 1,   default: false, null: false
175
+    t.integer  "failed_attempts",        limit: 4,   default: 0
176
+    t.string   "unlock_token",           limit: 191
177 177
     t.datetime "locked_at"
178
-    t.string   "username",               limit: 191,                 null: false, charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
179
-    t.string   "invitation_code",                                    null: false,                     collation: "utf8_bin"
180
-    t.integer  "scenario_count",                     default: 0,     null: false
178
+    t.string   "username",               limit: 191,                              charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
179
+    t.string   "invitation_code",        limit: 191,                 null: false
180
+    t.integer  "scenario_count",         limit: 4,   default: 0,     null: false
181 181
   end
182 182
 
183 183
   add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree